const path = require('path');

const html = require('html-webpack-plugin')

const VueLoaderPlugin = require('vue-loader/lib/plugin');

const webpack = require('webpack')

module.exports = {
    entry: path.join(__dirname, './src/main.js'),
    output: {
        path: path.join(__dirname, './dist'),
        filename: 'bundle.js',
    },
    plugins: [
        new html({
            template: path.join(__dirname, './src/index.html'),
            filename: 'index.html'
        }),
        new VueLoaderPlugin(),
        new webpack.ProvidePlugin({
            jQuery:"jquery",
            $:"jquery"
        })
    ],
    module: {
        rules: [{
                test: /\.js$/,
                use: 'babel-loader',
                exclude: /node_modules/
            },
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader']
            }, {
                test: /\.vue$/,
                use: 'vue-loader',
            }, {
                test: /\.less$/,
                use: ['style-loader', 'css-loader', 'less-loader']
            }, {
                test: /\.(png|jpg|gif)$/,
                use: 'url-loader?limit=43960'
            }, {
                test: /\.(ttf|eot|svg|woff|woff2)$/,
                use: 'url-loader'
            }
        ]
    },
    resolve: {
        alias: {
            'vue': 'vue/dist/vue.js'
        }
    },
    devServer: { //开发服务器配置
        // port: 8001,
        inline: true,
        compress: true,     // 一切服务都启用 gzip 压缩：
        // historyApiFallback: true,     // 任意的 404 响应都可能需要被替代为 index.html。
        progress: true,     // 将运行进度输出到控制台。
        proxy: {
            "/api": {
                target: 'http://news-at.zhihu.com',
                pathRewrite: {
                    '^/api': 'http://news-at.zhihu.com'
                },
                changeOrigin: true
            }
        },
    },
}